package spring.boot.shiro.config;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;

/**
 * Created by Administrator on 2018/6/10.
 */
public class Creadential extends SimpleCredentialsMatcher {

    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        System.out.println("###########密码校验#############");
        UsernamePasswordToken usernamePasswordToken = (UsernamePasswordToken) token;
        //用户传入密码
        String passwd = new String(usernamePasswordToken.getPassword());
        //数据库获取的密码
        String dbpasswd = (String) info.getCredentials();
        //自己实现比较方法
        return passwd.equals(dbpasswd);
    }
}
